package com.lt.basic.project.pojo.validate.admin.resource;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.lt.basic.project.common.util.StringUtils;
import com.lt.basic.project.pojo.entity.admin.resource.File;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * 文件管理(db_file)搜素对象
 * @author ：LT
 * @Created in : 2023-08-25
 */
@Data
@ApiModel(value="File搜素对象", description = "文件管理搜素对象")
public class FileSearchValidate implements Serializable {

    private static final long serialVersionUID=1L;



    /**
     * 文件名称
     */
    @ApiModelProperty(value = "文件名称")
    private String name;

    /**
     * 发布时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty(value = "发布时间")
    private Date publishTime;

    /**
     * 是否有效
     */
    @ApiModelProperty(value = "是否有效")
    private Boolean isEffective;

    /**
     * 文件路径
     */
    @ApiModelProperty(value = "文件路径")
    private String url;

    /**
     * 类型
     */
    @ApiModelProperty(value = "类型")
    private Integer type;




    /**
    * 查询数据过滤
    */
    public void query(FileSearchValidate searchValidate, LambdaQueryWrapper<File> lqw) {
        if (StringUtils.isNotObj(searchValidate.getName())) {
            lqw.eq(File::getName, searchValidate.getName());
        }
        if (StringUtils.isNotObj(searchValidate.getPublishTime())) {
            lqw.eq(File::getPublishTime, searchValidate.getPublishTime());
        }
        if (StringUtils.isNotObj(searchValidate.getIsEffective())) {
            lqw.eq(File::getIsEffective, searchValidate.getIsEffective());
        }
        if (StringUtils.isNotObj(searchValidate.getUrl())) {
            lqw.eq(File::getUrl, searchValidate.getUrl());
        }
        if (StringUtils.isNotObj(searchValidate.getType())) {
            lqw.eq(File::getType, searchValidate.getType());
        }
        lqw.eq(File::getIsDel, false);
    }

}